Method and apparatus for coding video, electronic device and computer-readable storage medium

ABSTRACT

A method and apparatus for coding a video, an electronic device and a computer-readable storage medium. A specific implementation scheme is: coding a sampled video frame sequence of a source video by using a preset coding mode to obtain a sample coding overhead; analyzing frame types of frames to be coded in the source video to obtain a frame type sequence of the frames to be coded; determining a predictive coding overhead of the source video according to the sample coding overhead of the source video, the frame type sequence of the frames to be coded, and quantization parameters of coding modes to be used corresponding to different frame types; and determining a coding strategy based on the predictive coding overhead and requirements of transmission bit rate limit information.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application claims priority to Chinese Patent Application No.202010773759.9, filed with the China National Intellectual PropertyAdministration (CNIPA) on Aug. 4, 2020, the contents of which areincorporated herein by reference in their entirety.

TECHNICAL FIELD

The present disclosure relates to the field of cloud computingtechnology, particularly to the fields of video processing technology,video coding technology and communication transmission technology, andmore particularly to a method and apparatus for coding a video, anelectronic device and a computer-readable storage medium.

BACKGROUND

A video is a continuous sequence of images, and is composed ofcontinuous frames, wherein one frame is one image. Due to thepersistence effect of human eyes, when a sequence of frames is played ata certain rate, what we see is a video with continuous motions.

There are similarities among the continuous frames, and thus in order tofacilitate storage and transmission, the original video needs to becoded and compressed to remove redundancy in spatial and temporaldimensions in the prior art.

SUMMARY

Embodiments of the present disclosure provide a method and apparatus forcoding a video, an electronic device and a computer-readable medium.

In a first aspect, embodiments of the present disclosure provide amethod for coding a video, comprising: coding a sampled video framesequence of a source video by using a preset coding mode to obtain asample coding overhead; analyzing frame types of frames to be coded inthe source video to obtain a frame type sequence of the frames to becoded; determining a predictive coding overhead of the source videoaccording to the sample coding overhead of the source video, the frametype sequence of the frames to be coded, and quantization parameters ofcoding modes to be used corresponding to different frame types; anddetermining a coding strategy based on the predictive coding overheadand requirements of transmission bit rate limit information.

In a second aspect, embodiments of the present disclosure provide anapparatus for coding a video, comprising: a pre-coding unit, configuredto code a sampled video frame sequence of a source video by using apreset coding mode to obtain a sample coding overhead; a frame typeanalysis unit, configured to analyze frame types of frames to be codedin the source video to obtain a frame type sequence of the frames to becoded; a coding overhead prediction unit, configured to determine apredictive coding overhead of the source video according to the samplecoding overhead of the source video, the frame type sequence of theframes to be coded, and quantization parameters of coding modes to beused corresponding to different frame types; and a strategydetermination unit, configured to determine a coding strategy based onthe predictive coding overhead and requirements of transmission bit ratelimit information.

In a third aspect, embodiments of the present disclosure provide anelectronic device, comprising: one or more processors; and a memory,storing one or more programs, wherein the one or more programs, whenexecuted by the one or more processors, cause the one or more processorsto implement the method for coding a video provided by the first aspect.

In a forth aspect, embodiments of the present disclosure provide acomputer-readable medium, storing a computer program thereon, whereinthe program, when executed by a processor, causes the processor toimplement the method for coding a video provided by the first aspect.

According to the present disclosure, a sampled video frame sequence of asource video is coded by using a pre-coding mode to obtain a samplecoding overhead, a coding overhead is subsequently predicted for frametypes of different frames to be coded in the source video andquantization parameters corresponding to coding modes to be used, andthe predicted coding overhead is compared with transmission bit ratelimit information to determine a coding strategy, so that bit rateallocation is performed in a more reasonable manner to improve thequality of video coding.

It should be understood that the content described in this section isneither intended to identify key or important features of theembodiments of the present disclosure, nor intended to limit the scopeof the present disclosure. Other features of the present disclosure willbecome understandable through the following description.

BRIEF DESCRIPTION OF THE DRAWINGS

The accompanying drawings are used to better understand the solution anddo not constitute limitations to the present disclosure. In the figures:

FIG. 1 is an exemplary system architecture to which the presentdisclosure may be applied;

FIG. 2 is a flowchart of an embodiment of a method for coding a videoaccording to the present disclosure;

FIG. 3 is a flowchart of another embodiment of a method for coding avideo according to the present disclosure;

FIG. 4 is a flowchart of a method for determining transmission bit ratelimit information in the method for coding a video according to thepresent disclosure;

FIG. 5 is a flowchart of another embodiment of a method for coding avideo according to the present disclosure;

FIG. 6 is a schematic structural diagram of an embodiment of anapparatus for coding a video according to the present disclosure; and

FIG. 7 is a block diagram of an electronic device suitable forimplementing video coding according to an embodiment of the presentdisclosure.

DETAILED DESCRIPTION OF EMBODIMENTS

Exemplary embodiments of the present disclosure will be described belowin combination with the accompanying drawings, which comprise variousdetails of the embodiments of the present disclosure to facilitateunderstanding and should be regarded as merely exemplary. Therefore, itshould be appreciated by those of ordinary skill in the art that variouschanges and modifications may be made to the embodiments described herewithout departing from the scope and spirit of the present disclosure.Likewise, for clarity and conciseness, descriptions of well-knownfunctions and structures are omitted in the following description.

It should also be noted that the embodiments in the present disclosureand the features in the embodiments may be combined with each other on anon-conflict basis. The present disclosure will be described below indetail with reference to the accompanying drawings and in combinationwith the embodiments.

FIG. 1 shows an exemplary system architecture 100 to which a method andapparatus for coding a video, an electronic device and acomputer-readable medium according to the embodiments of the presentdisclosure may be applied.

As shown in FIG. 1, the system architecture 100 may comprise a terminaldevice 101, 102, and 103, a network 104, and a server 105. The network104 serves as a medium providing a communication link between theterminal device 101, 102, or 103 and the server 105. The network 104 maycomprise various types of connections, such as wired or wirelesscommunication links, or optical fiber cables.

A user may use the terminal device 101, 102 or 103 to interact with theserver 105 through the network 104 to receive a video playback requestor send videos. The terminal device 101, 102 or 103 may be installedwith various applications for video interaction, such as onlinevideo-on-demand applications, video upload applications, socialapplications, etc.

The terminal device 101, 102 or 103 may be hardware or software. Whenthe terminal device 101, 102, or 103 is hardware, the terminal devicemay be various electronic devices with a display screen, including butnot limited to a smart phone, a tablet computer, a laptop computer and adesktop computer. When the terminal device 101, 102, or 103 is software,the terminal device may be installed in the above-listed electronicdevices. The terminal device may be implemented as a plurality ofsoftware programs or software modules (for example, used to implementvideo coding services), or as a single software program or softwaremodule. Specific limitations are not given here.

The server 105 may be a server that provides various services, forexample, acquires, through the network 104, a video playback requestfrom the terminal device 101, 102, or 103 that receives a coded sourcevideo in the present disclosure, and codes a sampled video framesequence of the source video by using a preset coding mode to obtain asample coding overhead; analyzes frame types of frames to be coded inthe source video to obtain a frame type sequence of the frames to becoded; determines a predictive coding overhead of the source videoaccording to the sample coding overhead of the source video, the frametype sequence of the frames to be coded, and quantization parameters ofcoding modes to be used corresponding to different frame types; anddetermines a coding strategy based on the predictive coding overhead andthe requirements of transmission bit rate limit information.

It should be noted that the method for coding a video according to theembodiments of the present disclosure may be executed by the server 105,and accordingly, the apparatus for coding a video may be configured inthe server 105.

The server 105 may be a server that provides various services, forexample, a back-end server that provides support for informationdisplayed on the terminal device 101, 102, or 103. The back-end servermay analyze the received data such as images and vehicle positioninformation, and feed processing results (such as position informationof a target element) back to the terminal device.

It should be noted that the server may be hardware or software. When theserver is hardware, the server may be implemented as a distributedserver cluster composed of a plurality of servers, or as a singleserver. When the server 105 is software, the server may be implementedas a plurality of software programs or software modules (for example,used to provide distributed services), or as a single software programor software module. Specific limitations are not given here.

It should be understood that the numbers of the terminal devices,networks, and servers in FIG. 1 are merely illustrative. Any number ofterminal devices, networks and servers may be configured according toactual requirements.

It should be pointed out that the terminal device 101, 102 or 103 mayalso be installed with applications for coding a video, and the terminaldevice 101, 102 or 103 may also complete video coding. Code a sampledvideo frame sequence of a source video by using a preset coding mode toobtain a sample coding overhead; analyze frame types of frames to becoded in the source video to obtain a frame type sequence of the framesto be coded; determine a predictive coding overhead of the source videoaccording to the sample coding overhead of the source video, the frametype sequence of the frames to be coded, and quantization parameters ofcoding modes to be used corresponding to different frame types; anddetermine a coding strategy based on the predictive coding overhead andrequirements of transmission bit rate limit information. At this time,the method for coding a video may be executed by the terminal device101, 102 or 103. Accordingly, the apparatus for coding a video may bearranged in the terminal device 101, 102 or 103. At this time, theexemplary system architecture 100 may not comprise the server 105 andthe network 104.

It should be understood that numbers of terminal devices, networks, andservers in FIG. 1 are merely illustrative. There may be any numbers ofterminal devices, networks and servers according to implementationneeds.

Continuing to refer to FIG. 2, a flow 200 of an embodiment of a methodfor coding a video according to the present disclosure is shown. Themethod for coding a video comprises the following steps:

Step 201: coding a sampled video frame sequence of a source video byusing a preset coding mode to obtain a sample coding overhead.

In this embodiment, the execution subject (for example, the server 105or the terminal device 101, 102, or 103 shown in FIG. 1) of the methodfor coding a video may acquire the source video from a local ornon-local storage device (for example, the terminal device 101, 102, or103 shown in FIG. 1).

The local storage device may be a data storage module configured in theexecution subject, and in this case, the source video may be acquiredonly by reading locally. The non-local storage device may also be otherdata storage server special for storing the source video, and in thiscase, the execution subject may send a source video acquisition commandto the data storage server to acquire the source video returned by thedata storage server.

Specifically, the acquired source video is coded by using a presetcoding mode. The preset coding mode is a common mode for coding a video,such as a Motion Picture Experts Group (MPEG) coding mode, an AudioVideo Interleaved (AVI) coding mode and a Flash Video (FLV) coding mode.After the source video is pre-coded by using the preset coding mode,quantization parameters corresponding to the preset coding mode, andinformation such as the number of bits consumed for intra-frame coding,the number of bits consumed for inter-frame coding, and the ratio ofintra-frame blocks in inter-frame coding in the coding results, are usedas the sample coding overhead.

On this basis, after the part to be coded in the source video isdetermined, the source video may be sampled to obtain the video framesequence of the source video, and the video frame sequence may be coded.

Step 202: analyzing frame types of frames to be coded in the sourcevideo to obtain a frame type sequence of the frames to be coded.

Specifically, analyzing the frame types of the frames to be coded in thesource video is generally to divide the frame types of the frames to becoded according to different information required for the frames to becoded, for example, the analysis results are divided into intra-framecoded frames, forward predictive coded frames and bidirectionaldifferential coded frames, according to whether data of other framesneeds to be referred during coding.

The intra-frame coded frame is an independent frame with all its owninformation, may be decoded independently without referring to otherimages, and may be simply interpreted as a still image. The forwardcoded frame is a frame that may be coded by referring to the previousintra-frame coded frames or forward coded frames. The forward codedframe represents the difference between the current frame of image andthe previous frame (the previous frame may be an intra-frame coded frameor a forward coded frame). When the forward coded frame is decoded, thepreviously cached image is superimposed with the difference defined bythis frame to generate a final image. The bidirectional differentialcoded frame records the difference between the current frame and theprevious and subsequent frames, that is, a corresponding decodedbidirectional differential coded frame, in which not only the previouslycached image but also the decoded image need to be acquired, and theprevious and subsequent images are superimposed with the current frameof data to obtain a final image.

It should be understood that, after the sampled video frame sequence inthe source video is coded by using the preset coding mode, the frametype sequence of the frames to be coded may be obtained according to thetypes of the frames to be coded in the coded sampled video framesequence.

Step 203: determining a predictive coding overhead of the source videoaccording to the sample coding overhead of the source video, the frametype sequence of the frames to be coded, and quantization parameters ofcoding modes to be used corresponding to different frame types.

Specifically, according to the types of the frame sequence obtained instep 202, when the execution subject codes the sampled video framesequence in the source video by using the preset coding mode, the samplecoding overhead corresponding to the types of frames to be coded may beobtained, and then the coding overhead required when coding the types offrames to be coded by using the coding modes to be used may be predictedaccording to the different types of the frames to be coded and thecoding modes selected corresponding to the types.

Exemplarily, when the analysis results of the frames to be coded areintra-frame coded frames, since the type of the intra-frame coded framesonly refers to the sample coding overhead of the current frame of theframes to be coded, then after the quantization parameter correspondingto the preset coding mode in the sample code is obtained, a conversionproportion relationship is determined according to the quantizationparameter corresponding to the preset coding mode and the quantizationparameter corresponding to the coding mode to be used, and thepredictive coding overhead corresponding to the coding mode to be usedis predicted according to the conversion proportion relationship and thecoding overhead corresponding to the coding mode according to the codingoverhead consumed by the coding mode.

Step 204: determining a coding strategy based on the predictive codingoverhead and the requirements of transmission bit rate limitinformation.

Specifically, after the predictive coding overhead corresponding to thecoding mode to be used is obtained, it is determined whether thepredictive bit rate overhead meets the requirements of the transmissionbit rate limit information; if the predictive bit rate overhead meetsthe requirements, the source video may be coded by using the coding modeto be used; and if the predictive bit rate overhead does not meet therequirements, other coding mode to be used is used or the quantizationparameters in the coding mode to be used are adjusted, so that thepredictive bit rate overhead meets the requirements of the bit ratelimit information.

In the method for coding a video according to the embodiment of thepresent disclosure, a sampled video frame sequence of a source video iscoded by using a preset coding mode to obtain a sample coding overhead;frame types of frames to be coded in the source video are analyzed toobtain a frame type sequence of the frames to be coded; a predictivecoding overhead of the source video is determined according to thesample coding overhead of the source video, the frame type sequence ofthe frames to be coded, and quantization parameters of coding modes tobe used corresponding to different frame types; and a coding strategy isdetermined based on the predictive coding overhead and the requirementsof transmission bit rate limit information. The method for coding avideo according to the present disclosure may determine the codingstrategy based on the predictive coding overhead and the requirements ofthe transmission bit rate limit information, so that bit rate allocationis performed in a more reasonable manner to improve the quality of videocoding.

Continuing to refer to FIG. 3, a flow 300 of another embodiment of amethod for coding a video according to the present disclosure is shown.The flow of predictive coding overhead of frames to be coded whose typesare intra-frame coded frames is shown, including the following steps:

Step 301: coding a sampled video frame sequence of a source video byusing a preset coding mode to obtain a sample coding overhead.

Step 302: analyzing frame types of frames to be coded in the sourcevideo to obtain a frame type sequence of the frames to be coded.

Step 303: in response to determining the frame types of the frames to becoded being intra-frame coded frames, determining predictive codingquantization parameter conversion coefficients according to the samplecoding overhead.

Specifically, after the frame types of the frames to be coded aredetermined to be intra-frame coded frames, the number of bits consumedby intra-frame coding in the sample coding overhead of the frames to becoded is substituted into linear relationships of the quantizationparameter conversion coefficients determined based on historical datastatistics:f1=a ₀*bitsI ² +a ₁*bitsI+a ₂.f2=b ₀*bitsI ² +b ₁*bitsI+b ₂.f3=c ₀*bitsI ² +c ₁*bitsI+c ₂.

Where, f1, f2, f3 are predictive coding quantization parameterconversion coefficients, bitsI is the number of bits consumed inintra-frame coding, and a₀, a₁, a₂, b₀, b₁, b₂, c₀, c₁, and c₂ areconstant variables in the linear relationships of the currentquantization parameter conversion coefficients determined based onhistorical data. The linear relationships of the quantization parameterconversion coefficients are used to determine the first, second, andthird predictive coding quantization parameter conversion coefficients.

Step 304: obtaining a first quantization parameter corresponding to afirst coding mode to be used, and determining a first quantizationcoefficient according to the predictive coding quantization parameterconversion coefficient and the first quantization parameter.

Specifically, a first quantization parameter-coefficient linearrelationship determined based on historical data is used:f5=f1*qp ² +f2*qp+f3

Where, f5 is the first quantization coefficient, f1, f2, and f3 are thefirst, second, and third predictive coding quantization parameterconversion coefficients obtained in step 303, and qp is the firstquantization parameter corresponding to the first coding mode. The firstquantization parameter-coefficient linear relationship is used todetermine the first quantization coefficient.

Step 305: calculating, according to a preset quantization parametercorresponding to the preset coding mode and a quantization scalarcorresponding to the first quantization parameter, a quantization scalarcorresponding to the preset quantization parameter and a firstquantization scalar corresponding to the first quantization parameterrespectively by using a quantization parameter-quantization scalarconversion formula.

Specifically, after the frame types of the frames to be coded aredetermined to be intra-frame coded frames, the first quantizationparameter corresponding to the quantization parameter of the coding modeto be used is obtained, and according to the quantizationparameter-quantization scalar conversion formula:qp=12.0+6.0*log₂(qscale/0.85)

Where qp is the quantization parameter, and qscale is the quantizationscale. The quantization parameter-quantization scalar conversion formulais used to respectively determine the preset quantization parameter andthe first quantization parameter, the corresponding preset quantizationscalar and the first quantization scalar.

Step 306: determining a predictive coding overhead of the intra-framecoded frames of the source video according to a coding curve functionfor the intra-frame coded frames and the following first predictivecoding parameters: the sample coding overhead, the quantization scalarcorresponding to the preset quantization parameter corresponding to thepreset coding mode, the first quantization scalar corresponding to thefirst quantization parameter, and the first quantization coefficient;wherein the coding curve function for the intra-frame coded frames isobtained by fitting historical data of actual coding parameters.

Specifically, the coding curve function for the intra-frame coded framesis obtained by fitting historical data of actual coding parameters:estBitsI=f5*bitsI*qscale/estQ

Where, estBitsI is the predictive coding overhead of the intra-framecoded frames of the source video, f5 is the first quantizationcoefficient determined in step 304 above, bitsI is the coding overheadof the intra-frame coded frames in the sample coding overhead, qscale isthe preset quantization scalar obtained in step 305 above, and estQ isthe first quantization scalar obtained in the above step. The codingcurve function for the intra-frame coded frames is used to determine thepredictive coding overhead of the intra-frame coded frames of the sourcevideo.

In this embodiment, a flow for determining a to-be-coded predictivecoding overhead of an intra-frame coded frame type is provided on thebasis of the embodiment shown in FIG. 2, and the same parts as those ofthe embodiment shown in FIG. 2 are not repeated. Through this flow, thepredictive coding overhead of the intra-frame coded frame type of framesto be coded may be accurately determined, which provides data supportfor subsequent comparison based on the predictive coding overhead andtransmission bit rate limit information, and improves the accuracy ofselection of video coding quantization parameters.

In some optional implementation modes of this embodiment, thedetermining the first quantization coefficient according to thepredictive coding quantization parameter conversion coefficient and thefirst quantization parameter comprises: confining the obtained firstquantization coefficient by a predetermined threshold condition.

Specifically, an appropriate threshold condition may be selectedaccording to information such as usage requirements and characteristicsof the source video. After the first quantization coefficient isdetermined, whether the first quantization coefficient is within thethreshold condition is judged, for example:

${f\; 5} = \left\{ \begin{matrix}{{{f\; 5} = {{th}\; 1}},{{f\; 5} < {{th}\; 1}}} \\{{{f\; 5} = {f\; 5}},{{{th}\; 1} < {f\; 5} < {{th}\; 2}},} \\{{{f\; 5} = {{th}\; 2}},{{{th}\; 2} < {f\; 5}},}\end{matrix} \right.$

Where, f5 is the first quantization coefficient determined in the abovestep, and th1 and th2 are respectively predetermined thresholdconditions. The corresponding relationship may confine the firstquantization coefficient by setting the threshold condition to ensurethat the quantization information is within a preset range, so as toensure that the data obtained when the first quantization coefficient isused for subsequent operations meets condition requirements.

In some optional implementation modes of this embodiment, thedetermining a coding strategy based on the predictive coding overheadand the requirements of transmission bit rate limit informationcomprises:

in response to the predictive coding overhead of the intra-frame codedframes of the source video meeting the requirements of the transmissionbit rate limit information, coding the intra-frame coded frames in theframes to be coded by using the first quantization parameter.

Specifically, after the transmission bit rate limit information isacquired, the acquired transmission bit rate limit information iscompared with the determined predictive coding overhead, usually bycomparing a bit value corresponding to the predictive coding overheadwith a bit value allowed to pass in the transmission bit rate limitinformation. If the bit value corresponding to the predictive codingoverhead is smaller than or equal to the bit value allowed to pass, itis considered to meet the requirements of the transmission bit ratelimit information, and the intra-frame coded frames in the frames to becoded may be coded by using the first quantization parametercorresponding to the predictive coding overhead, to ensure that thesource video may be coded by using the first quantization parameter,thereby ensuring the reliability of the coding process.

In some optional implementation modes of this embodiment, thedetermining a coding strategy based on the predictive coding overheadand the requirements of transmission bit rate limit informationcomprises: in response to the predictive coding overhead of theintra-frame coded frames of the source video not meeting therequirements of the transmission bit rate limit information,re-determining the first quantization parameter according to thepredictive coding overhead of the intra-frame coded frames of the sourcevideo and the transmission bit rate limit information.

Specifically, after the transmission bit rate limit information isacquired, the acquired transmission bit rate limit information iscompared with the determined predictive coding overhead, usually bycomparing a bit value corresponding to the predictive coding overheadwith a bit value allowed to pass in the transmission bit rate limitinformation. If the bit value corresponding to the predictive codingoverhead is greater than the bit value allowed to pass, it is consideredto not meet the requirements of the transmission bit rate limitinformation, the intra-frame coded frames in the frames to be coded maynot be coded by using the first quantization parameter corresponding tothe predictive coding overhead, but a new first quantization parameterneeds to be determined to ensure that the source video may be coded byusing the first quantization parameter, thereby ensuring the reliabilityof the coding process.

In some optional implementation modes of this embodiment, thetransmission bit rate limit information is determined based on thefollowing steps:

Specifically, as shown in FIG. 4, in a flow 400, step 401 is:determining a to-be-coded proportion coefficient of the source videoaccording to the sample coding overhead.

Specifically, in the obtained sample coding overhead of the sourcevideo, the number of bits consumed for intra-frame coding of the currentframe and the number of bits consumed for inter-frame coding ofsubsequent frames are substituted into the linear relationship of theto-be-coded proportion coefficient determined based on historical data:

${f\; 4} = {{d_{0}*\frac{bitsI}{bitsPB}} + d_{1}}$

Where, f4 is the to-be-coded proportion coefficient, bitsI is the numberof bits consumed for intra-frame coding of the current frame, bitsPB isthe number of bits consumed for inter-frame coding of subsequent frames,and d₀ and d₁ are constants of the to-be-coded proportion coefficientdetermined based on historical data. The linear relationship of theto-be-coded proportion coefficient is used to determine the to-be-codedproportion coefficient.

Step 402: determining a bit rate limit correction coefficient accordingto the sample coding overhead, the to-be-coded proportion coefficient,and the first quantization parameter.

Specifically, according to the to-be-coded proportion coefficientobtained in the above step and the preset quantization parametercorresponding to the pre-coding mode, a coding-limit proportioncoefficient conversion relationship determined based on historical datais used:

${f\; 6} = \left\{ \begin{matrix}{{e_{0}*f\; 4},{{qp} < {t\; 1}}} \\{{{\left( {1 - e_{0}} \right)*f\; 4*\frac{{qp} - {t\; 1}}{{t\; 2} - {t\; 1}}} + {t\; 1}},{{t\; 1} < {qp} < {t\; 2}},} \\{{e_{1}*f\; 4*\left( {\frac{{t\; 3} - {qp}}{{t\; 3} - {t\; 2}} + 1} \right)},{{t\; 2} < {qp} < {t\; 3}},} \\{{e_{1}*f\; 4},{{t\; 3} < {qp}},}\end{matrix} \right.$

Where, qp is the preset quantization parameter corresponding to thepre-coding mode, f4 is the to-be-coded proportion coefficient, t1, t2,and t3 are boundary values of a quantization parameter threshold rangecorresponding to the conversion relationship between coding proportioncoefficients and limit proportion coefficients determined based onhistorical data, and e₀ and e₁ are constants of the conversionrelationship between coding proportion coefficients and limit proportioncoefficients determined based on historical data. The coding-limitproportion coefficient conversion relationship is used to determine thebit rate correction coefficient.

Step 403: acquiring initial transmission bit rate limit information.

Step 404: determining the transmission bit rate limit informationaccording to the bit rate limit correction coefficient and the initialtransmission bit rate limit information.

The bit rate correction coefficient determined in step 402 above ismultiplied by the bit value allowed to pass in the initial transmissionbit rate limit information acquired in step 403 to determine a correctedbit value allowed to pass, and the corrected bit value allowed to passis used as the transmission bit rate limit information.

The transmission bit rate limit information is corrected in the abovesteps of the flow 400, so that the transmission bit rate limitinformation is adjusted for uncoded video frames, the transmission bitrate limit information is more accurate, the influence of coded frameson the transmission bit rate limit information is reduced, and thetransmission efficiency is improved by increasing the utilization of atransmission channel.

Continuing to refer to FIG. 5, a flow 500 of another embodiment of amethod for coding a video according to the present disclosure is shown.The flow of predictive coding overhead of frames to be coded whose typesare forward predictive coded frames is shown, including the followingsteps:

Step 501: coding a sampled video frame sequence of a source video byusing a preset coding mode to obtain a sample coding overhead.

Step 502: analyzing frame types of frames to be coded in the sourcevideo to obtain a frame type sequence of the frames to be coded.

Step 503: in response to determining that the frame types of the framesto be coded are forward predictive coded frames, obtaining thetransmission bit rate limit information and the preset codingquantization scalar corresponding to the preset coding moderespectively; and

determining a predictive coding overhead of the forward predictive codedframes of the source video according to a coding curve function for theforward predictive coded frames and the following second predictivecoding parameters: the transmission bit rate limit information, thesample coding overhead, and the preset quantization scalar, wherein thecoding curve function for the forward predictive coded frames isobtained by fitting historical data of actual coding parameters.

Specifically, the coding curve function of the predictive coded framesis usually: an original coding-pre-coding conversion coefficient isequal to an average value calculated after accumulation of products ofthe number of bits consumed by respective coded frames in the samplecoding overhead and the quantization scalar corresponding to the usedcoding mode, divided by an average value of the number of bits consumedto code respective frames coded by the preset coding mode in the samplecoding overhead. According to this function relationship, the originalcoding-pre-coding conversion coefficient is obtained.

A bit value allowed to pass in the transmission bit rate limitinformation is obtained, and the product of the number of bits consumedfor pre-coding in the sample coding overhead and the originalcoding-pre-coding conversion coefficient is divided by the bit valueallowed to pass to determine a second predictive coding overheadcorresponding to a coding mode to be used.

Step 504: performing weighting calculation on the preset quantizationscalar corresponding to the preset coding mode and the secondquantization parameter determined according to the predictive codingoverhead of the forward predictive coded frames to determine an updatedsecond quantization parameter; wherein, the characteristic proportionparameter is determined according to a characteristic parameter curvefunction and the sample coding overhead.

Specifically, the corresponding second quantization parameter may bedetermined according to the second predictive coding overhead obtainedin step 503; afterwards, a weighting proportion coefficient isdetermined according to the following characteristic parameter curve

${weight} = {{f\; 8*\frac{bitsI}{bitsPB}} + {f\; 9*{intraRatio}} + {{f1}\; 0}}$

Where, weight represents the weighting proportion coefficient, bitsI isthe number of bits consumed for intra-frame coding, bitsPB is the numberof bits consumed for inter-frame pre-coding, intraRatio is the ratio ofintra-frame blocks, and f8, f9, and f10 are characteristic constantsdetermined based on historical data; finally, the second quantizationparameter determined in the above step is updated according to thedetermined weighting proportion coefficient.

Step 505: coding, according to the updated second quantizationparameter, the forward predictive coded frames in the frames to becoded.

In this embodiment, a flow for determining a to-be-coded predictivecoding overhead of a forward predictive coded frame type is provided onthe basis of the embodiment shown in FIG. 2, and the same parts as thoseof the embodiment shown in FIG. 2 are not repeated. Through this flow,the predictive coding overhead of the forward predictive coded frametype of frames to be coded may be accurately determined, which providesdata support for subsequently determining the second quantizationparameter according to the predictive coding overhead and thetransmission bit rate limit information; and the second quantizationparameter is adjusted according to the data to improve the accuracy ofselection of video coding quantization parameters.

In some optional implementation modes of this embodiment, the coding,based on the second quantization parameter, the forward predictive codedframes in the frames to be coded comprises: determining a codedproportion coefficient according to the number of coded frames and thenumber of frames to be coded in the sampled video sequence, anddetermining whether the coded proportion coefficient satisfies a presetthreshold condition; in response to determining that the codedproportion coefficient does not satisfy the preset threshold condition,adjusting the second quantization parameter according to the firstquantization parameter; and coding the forward predictive coded framesin the frames to be coded by using the adjusted second quantizationparameter.

Specifically, when the coded proportion coefficient determined accordingto the number of coded frames and the number of frames to be coded inthe source video is obtained according to the sampled video sequence,and when it is determined that the coded proportion coefficient does notsatisfy the preset threshold condition, the second quantizationparameter is adjusted by using the first quantization parameterdetermined in the above step, and the forward predictive coded frames inthe frames to be coded are coded using the frames coded by means of thesecond quantization parameter, to prevent the problem of cold startcaused by the absence of an available quantization parameter to code thevideo when the coded frames used for reference do not satisfy thethreshold condition.

In some optional implementation modes of this embodiment, the coding,based on the second quantization parameter, the forward predictive codedframes in the frames to be coded comprises: in response to determiningthat the coded proportion coefficient satisfies the preset thresholdcondition, coding the forward predictive coded frames in the frames tobe coded by using the second quantization parameter.

Specifically, when the coded proportion coefficient determined accordingto the number of coded frames and the number of frames to be coded inthe source video is obtained according to the sampled video sequence,and when it is determined that the coded proportion coefficientsatisfies the preset threshold condition, the forward predictive codedframes are coded by using the second quantization parameter determinedin the above step, and the video is coded by using the more accuratequantization parameter when the coded frames used for reference satisfythe threshold condition, thereby improving the effect of video coding.

In some optional implementation modes of this embodiment, in response todetermining that the frame types of the frames to be coded arebidirectional differential coded frames, a third quantization parameteris determined according to a quantization parameter for adjacent frames,wherein the quantization parameter for the adjacent frames comprises:the first quantization parameter corresponding to the intra-frame codedframes and/or the second quantization parameter corresponding to theforward predictive coded frames; and the bidirectional differentialcoded frames in the frames to be coded are coded by using the thirdquantization parameter.

Specifically, when it is determined that the frame types of the framesto be coded are bidirectional differential coded frames, the thirdquantization parameter is determined according to the quantizationparameter for the adjacent frames. For example, if the adjacent framesare intra-frame coded frames, the first quantization parametercorresponding to the predictive coding overhead of the intra-frame codedframes of the source video is determined as the third quantizationparameter according to the coding curve function for the intra-framecoded frames and the following first predictive coding parameters: thesample coding overhead, the preset quantization scalar corresponding tothe preset quantization parameter, the first quantization scalarcorresponding to the first quantization parameter, and the firstquantization coefficient, and the bidirectional differential codedframes in the frames to be coded are coded by using the thirdquantization parameter. Similarly, based on the characteristics of thebidirectional differential coded frames, when the adjacent frames are anintra-frame coded frame and a forward predictive coded frame (theprevious frame is an intra-frame coded frame and the latter frame is aforward predictive coded frame, or the previous frame is a forwardpredictive coded frame and the latter frame is an intra-frame codedframe), the first quantization parameter used for the intra-frame codedframe may be used as the third quantization parameter, or the secondquantization parameter corresponding to the forward predictive codedframe may also be used as the third quantization parameter. In this way,when the type of a frame to be coded is a bidirectional differentialcoded frame, coding may be performed directly with reference to thequantization parameter for the adjacent frames to improve the codingefficiency.

To deepen understanding, the present disclosure further provides aspecific implementation scheme in combination with a specificapplication scenario. In the present disclosure scenario, after theexecution subject of the method for coding a video acquires a sourcevideo, samples in the source video are coded by using a preset codingmode, and a preset quantization parameter and a preset quantizationcoefficient corresponding to the preset coding mode, and informationsuch as the number of bits consumed for intra-frame coding, the numberof bits consumed for inter-frame coding, and the ratio of intra-frameblocks in inter-frame coding in the coding results, are determined as asample coding overhead.

Frame types of frames to be coded in the source video are analyzed toobtain a frame type sequence of the frames to be coded. The frame typesequence comprises intra-frame coded frames, forward coded frames andbidirectional differential coded frames. A first quantization parameterused for coding the intra-frame coded frames is first determined.

After the frame types of the frames to be coded are determined to beintra-frame coded frames, linear relationships of quantization parameterconversion coefficients are determined based on historical datastatistics, where a₀, a₁, a₂, b₀, b₁, b₂, c₀, c₁, and c₂ arerespectively 1, 2, 200, 2, 1, 30, 3, 5, and 600. 500 bits, as the numberof bits consumed for intra-frame coding in the sample coding overhead ofthe frames to be coded, is substituted into the linear relationships ofthe quantization parameter conversion coefficients determined based onhistorical data statistics:f1=1*500²+2*500+200f2=2*500²+2*500+30f3=3*500²+5*500+600

The first, second, and third predictive coding quantization parameterconversion coefficients are determined to be 251200, 501030, and 753100,respectively.

A first quantization parameter-coefficient linear relationshipdetermined based on historical data is used:f5=f1*qp ² +f2*qp+f3

qb is the first quantization parameter 1 corresponding to the firstcoding mode, and the first quantization coefficient is determined to be1505330.

After the frame types of the frames to be coded are determined to beintra-frame coded frames, the first quantization parameter correspondingto the quantization parameter of a coding mode to be used is obtained,and according to a quantization parameter-quantization scalar conversionformula:qp=12.0+6.0*log₂(qscale/0.85)

the preset quantization parameter 2 and the first quantization parameter1, and the corresponding preset quantization scalar 0.27 and firstquantization scalar 0.24 are determined respectively.

A coding curve function for the intra-frame coded frames is obtained byfitting historical data of actual coding parameters:estBitsI=f5*bitsI*qscale/estQ

A predictive coding overhead 8.29×10¹⁸ of the intra-frame coded framesof the source video is determined.

The obtained first quantization coefficient is limited by apredetermined threshold condition.

An appropriate threshold condition 1.3×10⁶ or 1.6×10⁶ is selectedaccording to information such as usage requirements and characteristicsof the source video. After the first quantization coefficient isdetermined, the first quantization coefficient determined in the abovestep is determined to be between th1 and th2, and the first quantizationcoefficient determined in the above step is used as the firstquantization coefficient 1505330.

In the obtained sample coding overhead of the source video, d₀ and d₁ ina linear relationship of a to-be-coded proportion coefficient determinedbased on historical data are respectively 1 and 2, and the number ofbits consumed for intra-frame coding of the current frame and the numberof bits consumed for inter-frame coding of subsequent frames aresubstituted into the linear relationship of the to-be-coded proportioncoefficient determined based on historical data:

${f\; 4} = {{1*\frac{bitsI}{bitsPB}} + 2}$

bitsI is the number 500 of bits consumed for intra-frame coding of thecurrent frame, bitsPB is the number 700000 of bits consumed forinter-frame coding of subsequent frames, and the determined to-be-codedproportion coefficient is 0.0007.

According to the to-be-coded proportion coefficient obtained in theabove step, the preset quantization parameter corresponding to thepre-coding mode, boundary values t1=0.3, t2=0.5, and t3=1 of aquantization parameter threshold range corresponding to the conversionrelationship between coding proportion coefficients and limit proportioncoefficients determined based on historical data, e₀=1200, and e₁=2, thecoding-limit proportion coefficient conversion relationship determinedbased on historical data is used:f6=e ₀ *f4

A bit rate correction coefficient is determined to be 0.84.

Initial transmission bit rate limit information is acquired, andtransmission bit rate limit information 8.4×10²⁰ is determined accordingto the bit rate limit correction coefficient and the initialtransmission bit rate limit information 1×10²¹.

After the transmission bit rate limit information is obtained, a bitvalue corresponding to the predictive coding overhead is compared with abit value allowed to pass in the transmission bit rate limit informationto determine that the bit value corresponding to the predictive codingoverhead is smaller than the bit value allowed to pass, and theintra-frame coded frames in the frames to be coded are coded by usingthe first quantization parameter corresponding to the predictive codingoverhead.

Second, a second quantization parameter used for coding the forwardcoded frames is determined.

A coded proportion coefficient 0.4 determined according to the number ofcoded frames and the number of frames to be coded in the source video isobtained according to the sampled video sequence, and the codedproportion coefficient satisfies a preset threshold condition 0.5.

An average value 6×10²⁰ calculated after accumulation of products of thenumber of bits consumed by respective coded frames in the sample codingoverhead and the quantization scalar corresponding to the used codingmode is divided by an average value 8×10²⁰ of the number of bitsconsumed to code respective frames coded by the preset coding mode inthe sample coding overhead to determine an original coding-pre-codingconversion coefficient that is equal to 0.75.

The bit value 1×10²¹ allowed to pass in the transmission bit rate limitinformation is obtained, and the product 6.75×10²⁰ of the number 9×10²⁰of bits consumed for pre-coding in the sample coding overhead and theoriginal coding-pre-coding conversion coefficient 0.75 is divided by thebit value 1×10²¹ allowed to pass to determine that the secondquantization parameter corresponding to a second predictive codingoverhead using a coding mode to be used is 0.675.

The corresponding second quantization parameter is determined accordingto the second predictive coding overhead obtained in the above step, andaccording to a characteristic parameter curve:

${weight} = {{f\; 8\frac{bitsI}{bitsPB}} + {f\; 9*{intraRatio}} + {{f1}\; 0}}$

Where, weight represents a weighting proportion coefficient, bitsI isthe number 5×10⁸ of bits consumed for intra-frame coding, bitsPB is thenumber 1×10⁹ of bits consumed for inter-frame pre-coding, intraRatio isa ratio 0.3 of intra-frame blocks, characteristic constants f8, f9, andf10 determined based on historical data are respectively 0.2, 0.1, and0.2, the determined weighting proportion coefficient is 0.33, the secondquantization parameter is determined to be 0.538 (0.67*0.67+0.33*0.27)according to the determined weighting proportion coefficient, and thesecond quantization parameter determined in the above step is updated.

The forward predictive coded frames in the frames to be coded are codedaccording to the updated second quantization parameter.

Finally, a third quantization parameter used to code the bidirectionaldifferential coded frames is determined, adjacent frames are determinedto be intra-frame coded frames, the first quantization parameter 0.24 isused as the third quantization parameter, and the bidirectionaldifferential coded frames in the frames to be coded are coded by usingthe third quantization parameter 0.24.

It may be seen from this application scenario that, according to themethod for coding a video in the present disclosure, a sampled videoframe sequence of a source video is coded by using a preset coding modeto obtain a sample coding overhead; frame types of frames to be coded inthe source video are analyzed to obtain a frame type sequence of theframes to be coded; a predictive coding overhead of the source video isdetermined according to the sample coding overhead of the source video,the frame type sequence of the frames to be coded, and quantizationparameters of coding modes to be used corresponding to different frametypes; and a coding strategy is determined based on the predictivecoding overhead and the requirements of transmission bit rate limitinformation, so that bit rate allocation is performed in a morereasonable manner to improve the quality of video coding.

As shown in FIG. 6, an apparatus 600 for coding a video in thisembodiment may comprise: a pre-coding unit 601, configured to code asampled video frame sequence of a source video by using a preset codingmode to obtain a sample coding overhead; a frame type analysis unit 602,configured to analyze frame types of frames to be coded in the sourcevideo to obtain a frame type sequence of the frames to be coded; acoding overhead prediction unit 603, configured to determine apredictive coding overhead of the source video according to the samplecoding overhead of the source video, the frame type sequence of theframes to be coded, and quantization parameters of coding modes to beused corresponding to different frame types; and a strategydetermination unit 604, configured to determine a coding strategy basedon the predictive coding overhead and the requirements of transmissionbit rate limit information.

In some optional implementation modes of this embodiment, the codingoverhead prediction unit 603 determining a predictive coding overhead ofthe source video according to the sample coding overhead of the sourcevideo, the frame type sequence of the frames to be coded, andquantization parameters of coding modes to be used corresponding todifferent frame types comprises: in response to determining that theframe types of the frames to be coded are intra-frame coded frame type,obtaining a first quantization parameter corresponding to a coding modeto be used corresponding to the intra-frame coded frame type, andcalculating, according to a preset quantization parameter correspondingto the preset coding mode and a quantization scalar corresponding to thefirst quantization parameter, a preset quantization scalar correspondingto the preset quantization parameter and a first quantization scalarcorresponding to the first quantization parameter respectively by usinga quantization parameter-quantization scalar conversion formula; andaccording to a coding curve function for the intra-frame coded framesand the following first predictive coding parameters: the sample codingoverhead, the preset quantization scalar corresponding to the presetquantization parameter, the first quantization scalar corresponding tothe first quantization parameter, and a first quantization coefficient,determining the predictive coding overhead of the intra-frame codedframes of the source video; wherein the coding curve function for theintra-frame coded frames is obtained by fitting historical data ofactual coding parameters.

In some optional implementation modes of this embodiment, the step ofdetermining the first quantization coefficient in the coding overheadprediction unit 603 comprises: determining a predictive codingquantization parameter conversion coefficient according to the samplecoding overhead and linear relationships of quantization parameterconversion coefficients determined based on historical data statistics;obtaining the first quantization parameter corresponding to the firstcoding mode to be used, and determining the first quantizationcoefficient according to the predictive coding quantization parameterconversion coefficient and the first quantization parameter by using thefirst quantization parameter-coefficient linear relationship determinedbased on historical data.

In some optional implementation modes of this embodiment, thedetermining the first quantization coefficient according to thepredictive coding quantization parameter conversion coefficient and thefirst quantization parameter comprises: confining the obtained firstquantization coefficient by a predetermined threshold condition.

In some optional implementation modes of this embodiment, the strategydetermination unit 604 determining a coding strategy based on thepredictive coding overhead of the source video and the requirements oftransmission bit rate limit information comprises: in response to thepredictive coding overhead of the intra-frame coded frames of the sourcevideo meeting the requirements of the transmission bit rate limitinformation, coding the intra-frame coded frames in the frames to becoded by using the first quantization parameter.

In some optional implementation modes of this embodiment, the strategydetermination unit 604 determining a coding strategy based on thepredictive coding overhead of the source video and the requirements oftransmission bit rate limit information comprises: in response to thepredictive coding overhead of the intra-frame coded frames of the sourcevideo not meeting the requirements of the transmission bit rate limitinformation, re-determining the first quantization parameter accordingto the predictive coding overhead of the intra-frame coded frames of thesource video and the transmission bit rate limit information.

In some optional implementation modes of this embodiment, thetransmission bit rate limit information in the strategy determinationunit 604 is determined based on the following steps: determining ato-be-coded proportion coefficient of the source video according to thesample coding overhead; determining a bit rate limit correctioncoefficient according to the sample coding overhead, the to-be-codedproportion coefficient, and the first quantization parameter; acquiringinitial transmission bit rate limit information; and determining thetransmission bit rate limit information according to the bit rate limitcorrection coefficient and the initial transmission bit rate limitinformation.

In some optional implementation modes of this embodiment, the codingoverhead prediction unit 603 determining a predictive coding overhead ofthe source video according to the sample coding overhead of the sourcevideo, the frame type sequence of the frames to be coded, andquantization parameters of coding modes to be used corresponding todifferent frame types comprises: in response to determining that theframe types of the frames to be coded are forward predictive codedframes, obtaining the transmission bit rate limit information and thepreset coding quantization scalar corresponding to the preset codingmode respectively; and according to a coding curve function for theforward predictive coded frames and the following second predictivecoding parameters: the transmission bit rate limit information, thesample coding overhead, and the preset quantization scalar, determiningthe predictive coding overhead of the forward predictive coded frames ofthe source video, wherein the coding curve function for the forwardpredictive coded frames is obtained by fitting historical data of actualcoding parameters. The strategy determination unit determining a codingstrategy based on the predictive coding overhead of the source video andthe requirements of transmission bit rate limit information comprises:according to a characteristic proportion parameter of the source videoand the following parameters: the preset quantization scalarcorresponding to the preset coding mode and a second quantizationparameter determined according to the predictive coding overhead of theforward predictive coded frames, performing weighting calculation todetermine an updated second quantization parameter, wherein thecharacteristic proportion parameter is determined according to acharacteristic parameter curve function and the sample coding overhead;and coding, based on the updated second quantization parameter, theforward predictive coded frames in the frames to be coded.

In some optional implementation modes of this embodiment, the strategydetermination unit 604 coding, based on the second quantizationparameter, the forward predictive coded frames in the frames to be codedcomprises: determining a coded proportion coefficient according to thenumber of coded frames and the number of frames to be coded in thesampled video sequence, and determining whether the coded proportioncoefficient satisfies a preset threshold condition; in response todetermining that the coded proportion coefficient does not satisfy thepreset threshold condition, adjusting the second quantization parameteraccording to the first quantization parameter; and coding the forwardpredictive coded frames in the frames to be coded by using the adjustedsecond quantization parameter.

In some optional implementation modes of this embodiment, the strategydetermination unit 604 coding, based on the second quantizationparameter, the forward predictive coded frames in the frames to be codedcomprises: in response to determining that the coded proportioncoefficient satisfies the preset threshold condition, coding the forwardpredictive coded frames in the frames to be coded by using the secondquantization parameter.

In some optional implementation modes of this embodiment, the strategydetermination unit 604 is further configured to, in response todetermining that the frame types of the frames to be coded arebidirectional differential coded frames, determine a third quantizationparameter according to a quantization parameter for adjacent frames,wherein the quantization parameter for the adjacent frames comprises:the first quantization parameter corresponding to the intra-frame codedframes and/or the second quantization parameter corresponding to theforward predictive coded frames; and code the bidirectional differentialcoded frames in the frames to be coded by using the third quantizationparameter.

According to the embodiments of the present disclosure, the presentdisclosure further provides an electronic device and a readable storagemedium.

As shown in FIG. 7, which is a block diagram of an electronic device ofa method for coding a video according to an embodiment of the presentdisclosure. The electronic device is intended to represent various formsof digital computers, such as laptop computers, desktop computers,workbenches, personal digital assistants, servers, blade servers,mainframe computers, and other suitable computers. The electronic devicemay also represent various forms of mobile apparatuses, such as personaldigital processing, cellular phones, smart phones, wearable devices, andother similar computing apparatuses. The components shown herein, theirconnections and relationships, and their functions are merely examples,and are not intended to limit the implementation of the presentdisclosure described and/or claimed herein.

As shown in FIG. 7, the electronic device includes: one or moreprocessors 701, a memory 702, and interfaces for connecting variouscomponents, including high-speed interfaces and low-speed interfaces.The various components are connected to each other using differentbuses, and may be installed on a common motherboard or in other methodsas needed. The processor may process instructions executed within theelectronic device, including instructions stored in or on the memory todisplay graphic information of GUI on an external input/output apparatus(such as a display device coupled to the interface). In otherembodiments, a plurality of processors and/or a plurality of buses maybe used together with a plurality of memories if desired. Similarly, aplurality of electronic devices may be connected, and the devicesprovide some necessary operations (for example, as a server array, a setof blade servers, or a multi-processor system). In FIG. 7, one processor701 is used as an example.

The memory 702 is a non-transitory computer readable storage mediumprovided by the present disclosure. The memory stores instructionsexecutable by at least one processor, so that the at least one processorperforms the method for coding a video provided by the presentdisclosure. The non-transitory computer readable storage medium of thepresent disclosure stores computer instructions for causing a computerto perform the method for coding a video provided by the presentdisclosure.

The memory 702, as a non-transitory computer readable storage medium,may be used to store non-transitory software programs, non-transitorycomputer executable programs and modules, such as programinstructions/modules corresponding to the method for coding a video inthe embodiments of the present disclosure (for example, the pre-codingunit 601, the frame type analysis unit 602, coding overhead predictionunit 603, and the strategy determination unit 604 shown in FIG. 6). Theprocessor 701 executes the non-transitory software programs,instructions, and modules stored in the memory 702 to execute variousfunctional applications and data processing of the server, that is, toimplement the method for coding a video in the foregoing methodembodiment.

The memory 702 may include a storage program area and a storage dataarea, where the storage program area may store an operating system andat least one function required application program; and the storage dataarea may store data created by the use of the electronic deviceaccording to the method for coding a video, etc. In addition, the memory702 may include a high-speed random access memory, and may also includea non-transitory memory, such as at least one magnetic disk storagedevice, a flash memory device, or other non-transitory solid-statestorage devices. In some embodiments, the memory 702 may optionallyinclude memories remotely provided with respect to the processor 701,and these remote memories may be connected to the electronic device ofthe method for coding a video through a network. Examples of the abovenetwork include but are not limited to the Internet, intranet, localarea network, mobile communication network, and combinations thereof.

The electronic device of the method for coding a video may furtherinclude: an input apparatus 703 and an output apparatus 704. Theprocessor 701, the memory 702, the input apparatus 703, and the outputapparatus 704 may be connected through a bus or in other methods. InFIG. 7, connection through a bus is used as an example.

The input apparatus 703 may receive input digital or characterinformation, and generate key signal inputs related to user settings andfunction control of the electronic device of the method for coding avideo, such as touch screen, keypad, mouse, trackpad, touchpad, pointingstick, one or more mouse buttons, trackball, joystick and other inputapparatuses. The output apparatus 704 may include a display device, anauxiliary lighting apparatus (for example, LED), a tactile feedbackapparatus (for example, a vibration motor), and the like. The displaydevice may include, but is not limited to, a liquid crystal display(LCD), a light emitting diode (LED) display, and a plasma display. Insome embodiments, the display device may be a touch screen.

Various embodiments of the systems and technologies described herein maybe implemented in digital electronic circuit systems, integrated circuitsystems, dedicated ASICs (application specific integrated circuits),computer hardware, firmware, software, and/or combinations thereof.These various embodiments may include: being implemented in one or morecomputer programs that may be executed and/or interpreted on aprogrammable system that includes at least one programmable processor.The programmable processor may be a dedicated or general-purposeprogrammable processor, and may receive data and instructions from astorage system, at least one input apparatus, and at least one outputapparatus, and transmit the data and instructions to the storage system,the at least one input apparatus, and the at least one output apparatus.

These computing programs (also referred to as programs, software,software applications, or codes) include machine instructions of theprogrammable processor and may use high-level processes and/orobject-oriented programming languages, and/or assembly/machine languagesto implement these computing programs. As used herein, the terms“machine readable medium” and “computer readable medium” refer to anycomputer program product, device, and/or apparatus (for example,magnetic disk, optical disk, memory, programmable logic apparatus (PLD))used to provide machine instructions and/or data to the programmableprocessor, including machine readable medium that receives machineinstructions as machine readable signals. The term “machine readablesignal” refers to any signal used to provide machine instructions and/ordata to the programmable processor.

In order to provide interaction with a user, the systems andtechnologies described herein may be implemented on a computer, thecomputer has: a display apparatus for displaying information to the user(for example, CRT (cathode ray tube) or LCD (liquid crystal display)monitor); and a keyboard and a pointing apparatus (for example, mouse ortrackball), and the user may use the keyboard and the pointing apparatusto provide input to the computer. Other types of apparatuses may also beused to provide interaction with the user; for example, feedbackprovided to the user may be any form of sensory feedback (for example,visual feedback, auditory feedback, or tactile feedback); and any form(including acoustic input, voice input, or tactile input) may be used toreceive input from the user.

The systems and technologies described herein may be implemented in acomputing system that includes backend components (e.g., as a dataserver), or a computing system that includes middleware components(e.g., application server), or a computing system that includes frontendcomponents (for example, a user computer having a graphical userinterface or a web browser, through which the user may interact with theimplementations of the systems and the technologies described herein),or a computing system that includes any combination of such backendcomponents, middleware components, or frontend components. Thecomponents of the system may be interconnected by any form or medium ofdigital data communication (e.g., communication network). Examples ofthe communication network include: local area networks (LAN), wide areanetworks (WAN), and the Internet.

The computer system may include a client and a server. The client andthe server are generally far from each other and usually interactthrough the communication network. The relationship between the clientand the server is generated by computer programs that run on thecorresponding computer and have a client-server relationship with eachother.

According to the technical solution of the embodiment of the presentdisclosure, a sampled video frame sequence of a source video is coded byusing a preset coding mode to obtain a sample coding overhead; frametypes of frames to be coded in the source video are analyzed to obtain aframe type sequence of the frames to be coded; a predictive codingoverhead of the source video is determined according to the samplecoding overhead of the source video, the frame type sequence of theframes to be coded, and quantization parameters of coding modes to beused corresponding to different frame types; and a coding strategy isdetermined based on the predictive coding overhead and the requirementsof transmission bit rate limit information, so that bit rate allocationis performed in a more reasonable manner to improve the quality of videocoding.

It should be understood that the various forms of processes shown abovemay be used to reorder, add, or delete steps. For example, the stepsdescribed in the present disclosure may be performed in parallel,sequentially, or in different orders. As long as the desired results ofthe technical solution disclosed in the present disclosure may beachieved, no limitation is made herein.

The above specific embodiments do not constitute limitation on theprotection scope of the present disclosure. Those skilled in the artshould understand that various modifications, combinations,sub-combinations and substitutions may be made according to designrequirements and other factors. Any modification, equivalent replacementand improvement made within the spirit and principle of the presentdisclosure shall be included in the protection scope of the presentdisclosure.

What is claimed is:
 1. A method for coding a video, comprising: coding asampled video frame sequence of a source video by using a preset codingmode to obtain a sample coding overhead; analyzing frame types of framesto be coded in the source video to obtain a frame type sequence of theframes to be coded; obtaining a first quantization parametercorresponding to a coding mode to be used corresponding to anintra-frame coded frame type, in response to determining that the frametypes of the frames to be coded are intra-frame coded frame type, andcalculating a preset quantization scalar corresponding to a presetquantization parameter and a first quantization scalar corresponding tothe first quantization parameter respectively by using a quantizationparameter-quantization scalar conversion formula, according to a presetquantization parameter corresponding to the preset coding mode and aquantization scalar corresponding to the first quantization parameter;and determining a predictive coding overhead of intra-frame coded framesof the source video according to a coding curve function for theintra-frame coded frames and following first predictive codingparameters: the sample coding overhead, the preset quantization scalarcorresponding to the preset quantization parameter, the firstquantization scalar corresponding to the first quantization parameter,and a first quantization coefficient; wherein the coding curve functionfor the intra-frame coded frames is obtained by fitting historical dataof actual coding parameters; and determining a coding strategy based onthe predictive coding overhead and requirements of transmission bit ratelimit information.
 2. The method according to claim 1, wherein the firstquantization coefficient is determined based on the following steps:determining a predictive coding quantization parameter conversioncoefficient according to the sample coding overhead and linearrelationships of quantization parameter conversion coefficientsdetermined based on historical data statistics; and obtaining the firstquantization parameter corresponding to a first coding mode to be used,and determining the first quantization coefficient according to thepredictive coding quantization parameter conversion coefficient and thefirst quantization parameter by using a first quantizationparameter-coefficient linear relationship determined based on historicaldata.
 3. The method according to claim 2, wherein the determining thefirst quantization coefficient according to the predictive codingquantization parameter conversion coefficient and the first quantizationparameter comprises: confining the obtained first quantizationcoefficient by a predetermined threshold condition.
 4. The methodaccording to claim 1, wherein the determining a coding strategycomprises: coding the intra-frame coded frames in the frames to be codedby using the first quantization parameter, in response to the predictivecoding overhead of the intra-frame coded frames of the source videomeeting the requirements of the transmission bit rate limit information.5. The method according to claim 1, wherein the determining a codingstrategy comprises: re-determining the first quantization parameteraccording to the predictive coding overhead of the intra-frame codedframes of the source video and the transmission bit rate limitinformation, in response to the predictive coding overhead of theintra-frame coded frames of the source video not meeting therequirements of the transmission bit rate limit information.
 6. Themethod according to claim 1, wherein the transmission bit rate limitinformation is determined based on the following steps: determining ato-be-coded proportion coefficient of the source video according to thesample coding overhead; determining a bit rate limit correctioncoefficient according to the sample coding overhead, the to-be-codedproportion coefficient, and the first quantization parameter; acquiringinitial transmission bit rate limit information; and determining thetransmission bit rate limit information according to the bit rate limitcorrection coefficient and the initial transmission bit rate limitinformation.
 7. The method according to claim 1, wherein the determininga predictive coding overhead of the source video comprises: obtainingthe transmission bit rate limit information and a preset codingquantization scalar corresponding to the preset coding moderespectively, in response to determining that the frame types of theframes to be coded are forward predictive coded frames; and determiningthe predictive coding overhead of the forward predictive coded frames ofthe source video according to a coding curve function for the forwardpredictive coded frames and following second predictive codingparameters: the transmission bit rate limit information, the samplecoding overhead, and the preset quantization scalar, wherein the codingcurve function for the forward predictive coded frames is obtained byfitting historical data of actual coding parameters.
 8. The methodaccording to claim 7, wherein the determining a coding strategycomprises: performing weighting calculation according to acharacteristic proportion parameter of the source video and thefollowing parameters: the preset quantization scalar corresponding tothe preset coding mode and a second quantization parameter determinedaccording to the predictive coding overhead of the forward predictivecoded frames, to determine an updated second quantization parameter,wherein the characteristic proportion parameter is determined accordingto a characteristic parameter curve function and the sample codingoverhead; and coding, based on the updated second quantizationparameter, the forward predictive coded frames in the frames to becoded.
 9. The method according to claim 8, wherein the coding theforward predictive coded frames in the frames to be coded comprises:determining a coded proportion coefficient according to a number ofcoded frames and a number of frames to be coded in the sampled videosequence, and determining whether the coded proportion coefficientsatisfies a preset threshold condition; adjusting the secondquantization parameter according to the first quantization parameter, inresponse to determining that the coded proportion coefficient does notsatisfy the preset threshold condition; and coding the forwardpredictive coded frames in the frames to be coded by using the adjustedsecond quantization parameter.
 10. The method according to claim 9,wherein the coding the forward predictive coded frames in the frames tobe coded comprises: coding the forward predictive coded frames in theframes to be coded by using the second quantization parameter, inresponse to determining that the coded proportion coefficient satisfiesthe preset threshold condition.
 11. The method according to claim 8,further comprising: determining a third quantization parameter accordingto a quantization parameter for adjacent frames, in response todetermining that the frame types of the frames to be coded arebidirectional differential coded frames, wherein the quantizationparameter for the adjacent frames comprises: the first quantizationparameter corresponding to the intra-frame coded frames and/or thesecond quantization parameter corresponding to the forward predictivecoded frames; and coding the bidirectional differential coded frames inthe frames to be coded by using the third quantization parameter.
 12. Anelectronic device, comprising: at least one processor; and a memorycommunicatively connected to the at least one processor; wherein thememory stores instructions executable by the at least one processor, andthe instructions, when executed by the at least one processor, causesthe at least one processor to perform an operation for coding a video,comprising: coding a sampled video frame sequence of a source video byusing a preset coding mode to obtain a sample coding overhead; analyzingframe types of frames to be coded in the source video to obtain a frametype sequence of the frames to be coded; obtaining a first quantizationparameter corresponding to a coding mode to be used corresponding to anintra-frame coded frame type, in response to determining that the frametypes of the frames to be coded are intra-frame coded frame type, andcalculating a preset quantization scalar corresponding to a presetquantization parameter and a first quantization scalar corresponding tothe first quantization parameter respectively by using a quantizationparameter-quantization scalar conversion formula, according to a presetquantization parameter corresponding to the preset coding mode and aquantization scalar corresponding to the first quantization parameter;and determining a predictive coding overhead of intra-frame coded framesof the source video according to a coding curve function for theintra-frame coded frames and following first predictive codingparameters: the sample coding overhead, the preset quantization scalarcorresponding to the preset quantization parameter, the firstquantization scalar corresponding to the first quantization parameter,and a first quantization coefficient wherein the coding curve functionfor the intra-frame coded frames is obtained by fitting historical dataof actual coding parameters; and determining a coding strategy based onthe predictive coding overhead and requirements of transmission bit ratelimit information.
 13. A non-transient computer-readable storage mediumstoring computer instructions, wherein the computer instructions areused for a computer to perform an operation for coding a video,comprising: coding a sampled video frame sequence of a source video byusing a preset coding mode to obtain a sample coding overhead; analyzingframe types of frames to be coded in the source video to obtain a frametype sequence of the frames to be coded; obtaining a first quantizationparameter corresponding to a coding mode to be used corresponding to anintra-frame coded frame type, in response to determining that the frametypes of the frames to be coded are intra-frame coded frame type, andcalculating a preset quantization scalar corresponding to a presetquantization parameter and a first quantization scalar corresponding tothe first quantization parameter respectively by using a quantizationparameter-quantization scalar conversion formula, according to a presetquantization parameter corresponding to the preset coding mode and aquantization scalar corresponding to the first quantization parameter;and determining a predictive coding overhead of intra-frame coded framesof the source video according to a coding curve function for theintra-frame coded frames and following first predictive codingparameters: the sample coding overhead, the preset quantization scalarcorresponding to the preset quantization parameter, the firstquantization scalar corresponding to the first quantization parameter,and a first quantization coefficient wherein the coding curve functionfor the intra-frame coded frames is obtained by fitting historical dataof actual coding parameters; and determining a coding strategy based onthe predictive coding overhead and requirements of transmission bit ratelimit information.
 14. The medium according to claim 13, wherein thefirst quantization coefficient is determined based on the followingsteps: determining a predictive coding quantization parameter conversioncoefficient according to the sample coding overhead and linearrelationships of quantization parameter conversion coefficientsdetermined based on historical data statistics; and obtaining the firstquantization parameter corresponding to a first coding mode to be used,and determining the first quantization coefficient according to thepredictive coding quantization parameter conversion coefficient and thefirst quantization parameter by using a first quantizationparameter-coefficient linear relationship determined based on historicaldata.
 15. The medium according to claim 14, wherein the determining thefirst quantization coefficient according to the predictive codingquantization parameter conversion coefficient and the first quantizationparameter comprises: confining the obtained first quantizationcoefficient by a predetermined threshold condition.
 16. The mediumaccording to claim 13, wherein the determining a coding strategycomprises: coding the intra-frame coded frames in the frames to be codedby using the first quantization parameter, in response to the predictivecoding overhead of the intra-frame coded frames of the source videomeeting the requirements of the transmission bit rate limit information.17. The medium according to claim 13, wherein the determining a codingstrategy comprises: re-determining the first quantization parameteraccording to the predictive coding overhead of the intra-frame codedframes of the source video and the transmission bit rate limitinformation, in response to the predictive coding overhead of theintra-frame coded frames of the source video not meeting therequirements of the transmission bit rate limit information.
 18. Themedium according to claim 13, wherein the transmission bit rate limitinformation is determined based on the following steps: determining ato-be-coded proportion coefficient of the source video according to thesample coding overhead; determining a bit rate limit correctioncoefficient according to the sample coding overhead, the to-be-codedproportion coefficient, and the first quantization parameter; acquiringinitial transmission bit rate limit information; and determining thetransmission bit rate limit information according to the bit rate limitcorrection coefficient and the initial transmission bit rate limitinformation.